package com.laobiao.file_netty_lib.packet;

import com.laobiao.file_netty_lib.exception.FileBaseException;

/**
 * @author 38079
 *包类型
 *	0:命令包
 *	1:数据包
 */
public enum PacketType {
	COMMAND(0),//命令包
	DATA(1);//数据包
	private int type;
	
	PacketType(int type) {
		this.type=type;
	}
	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}
	
	public static PacketType instance(int type) {
		for(PacketType packetType : PacketType.values()) {
			if(packetType.getType()==type) {
				return packetType;
			}
		}
		throw new FileBaseException("数据错误，无法读取包类型", FileBaseException.ERR_PARAM_WRONG);
	}
}
